import base from '../base'
const nav = Pager.nav
const template = function(state, props) {
  return (
    <div className="page-loading">loading</div>
  )
}
export default function(Pager){
  const route = this
  return Pager({ 
    template,
    data: {},
    onLoad(param){
      this.redirectParam = param
    },
    onReady(){
      const param = this.redirectParam
      const tablename = param.tablename
      const title = param.title
      const newpage = function(p) {
        return base(p, {
          collectionName: tablename, 
          collectionTitle: title, 
          columnsName: tablename,
          events: {},
          template: null
        })
      }
      const url = '/collection/'+tablename
      const routerpageConfig = {url, content: newpage}
      route.appendPages([routerpageConfig])
      setTimeout(() => {
        nav.redirectTo({ url })
      }, 50)
    }
  })
}
